@extends('layouts.admin')
@section('title') @parent 编辑律师资料 @stop
@section('page_title')@parent
编辑律师资料
@show
@section('breadcrumb')@parent
{{ Breadcrumbs::render('article-create') }}
@show
@section('content')
<div class="row">
		@include('widgets.notification')
		<div class="col-md-12">
				<!-- general form elements -->
				<div class="box box-primary">
						<div class="box-header">
								<h3 class="box-title">编辑律师</h3>
						</div>
						<form fole="form" method="post" action="{{ route('admin.users.updatelawyer', $user->id) }}" enctype="multipart/form-data">
						<input type="hidden" name="_token" value="{{ csrf_token() }}" />
						<div class="box-body">
								<div class="form-group">
										<label for="class">手机号</label>
										{{ $user->phone }}
								</div>
								<div class="form-group">
										<label class="control-label" for="password">密码</label>
										<input name="password" value="" class="form-control" type="password"  placeholder="密码">
									    {{ $errors->first('password', '<strong class="error">:message</strong>') }}
							   </div>
								<div class="form-group">
										<label class="control-label" for="password_confirmation">确认密码</label>
										<input name="password_confirmation" value="" class="form-control" type="password"  placeholder="确认密码">
								</div>
								@if (isset($lawyer))
								<div class="form-group">
										<label for="realname">真实姓名</label>
										<input name="realname" id="realname" class="form-control" placeholder="真实姓名" value="{{ $user->realname }}" required>
										{{ $errors->first('realname', '<strong class="error">:message</strong>') }}
								</div>
								@endif
								<div class="form-group">
										<label>律师头像</label>
										<div class="controls">
											<div class="input-group">
												 <input class="input-file" name="avatar" type="file">
											</div>
										</div>
										<img src="{{ Config::get('app.url').'/'.$user->avatar }}" style="width:100px; height:auto;" >
								</div>
								<div class="form-group">
										<label for="title">邮箱</label>
										<input name="email" id="email" class="form-control" placeholder="邮箱" value="{{ $user->email }}">
										{{ $errors->first('email', '<strong class="error">:message</strong>') }}
								</div>
								<!-- <div class="form-group">
										<label for="province">省</label>
										<select name="province" id="field_province" default="{{ $user->province }}" required></select>
								</div>
								<div class="form-group">
										<label for="city">市</label>
										<select name="city" id="field_city" default="{{ $user->city }}" required></select>
								</div>
								<div class="form-group">
										<label for="district">区</label>
										<select name="district" id="field_district" default="{{ $user->district }}" ></select>
								</div>  -->
								<div class="form-group">
										<label>详细地址</label>
										<div class="controls">
											<div class="input-group">
												 <input class="form-control" name="address" value="{{ $user->address }}">
											</div>
										</div>
								</div>
								@if (isset($lawyer))
								<div class="form-group">
										<label for="license">律师证号</label>
										<input name="license" id="license" class="form-control" placeholder="律师证" value="{{  $lawyer->license }}">
								</div>
								<div class="form-group">
										<label>律师证</label>
										<div class="controls">
											<div class="input-group">
												 <input class="input-file" name="license_file" type="file">
											</div>
										</div>
                                        <img src="{{ Config::get('app.url').'/'.$lawyer->license_file }}" style="width:100px; height:auto;" >
								</div>
								<div class="form-group">
										<label for="company_name">所在律所</label>
										<input name="company_name" id="company_name" class="form-control" placeholder="所在律所" value="{{ $lawyer->company_name }}">
										{{ $errors->first('company_name', '<strong class="error">:message</strong>') }}
								</div>

								<div class="form-group">
										<label for="position">职位</label>
										<input name="position" id="position" class="form-control" placeholder="职位" value="{{ $lawyer->position }}">
										{{ $errors->first('position', '<strong class="error">:message</strong>') }}
								</div>
								<div class="form-group">
										<label for="practice_period">执业年限</label>
										<input name="practice_period" id="practice_period" class="form-control" placeholder="如数字：10" value="{{ $lawyer->practice_period }}">
										{{ $errors->first('practice_period', '<strong class="error">:message</strong>') }}
								</div>
								<div class="form-group">
										<label for="work_scope">业务范围</label>
										@foreach($work_scope_list AS $cat_id => $work_scope)
                                        <input type="checkbox" name="work_scope[]" class="ck" value="{{ $work_scope['key'] }}"@if(in_array($work_scope['key'], explode(',', $lawyer->work_scope)))checked @endif> {{ $work_scope['value'] }} &nbsp;
                                        @endforeach
								</div>
								<div class="form-group">
										<label for="introduce">律师简介</label>
										<textarea cols="80" rows="10" name="introduce" id="introduce" class="form-control">{{ $lawyer->introduce }}</textarea>
										{{ $errors->first('introduce', '<strong class="error">:message</strong>') }}
								</div>
								@endif
						</div>
						<div class="box-footer">
								<a href="{{ route('admin.users.index', $user->user_group_id) }}" class="btn btn-default btn-save">返 回</a>
								<button type="submit" class="btn btn-primary btn-save">保 存</button>
						</div>
						</form>
				</div>
		</div>
</div>
@stop
@section('end')
@parent
<script>
var area_data = {};
 //  $(document).on('change','#field_province', function(){
	// var val = $(this).val();
	// $(this).attr('default','');
	// $('#field_city').html('');
	// $('#field_district').html('');
	// var city_ele = $('#field_city');
	// var defval = '';
	// if (val != '') {
	//   defval = val.replace(/0000$/,'');
	// }else{
	//   return;
	// }
	// for (var key in area_data) {
	//   var k = String(key);
	//   if ( k.match(/^\d{4}00$/) && k.indexOf(defval)===0 ) {
	// 	var op = document.createElement('option');
	// 	op.value = k, op.innerHTML = area_data[k];
	// 	if ( $('#field_city').attr('default') && $('#field_city').attr('default') == k  ) {
	// 	  op.selected = true;
	// 	}
	// 	city_ele.append(op);
	//   }
	// }
	// city_ele.attr('default','')
	// city_ele.trigger('change');
 //  });
 //   $(document).on('change','#field_city', function(){
	// var val = $(this).val();
	// $(this).attr('default','');
	// $('#field_district').html('');
	// if (val != '') {
	//   defval = val.replace(/00$/,'');
	// }else{
	//   return;
	// }
	// var district_ele = $('#field_district');
	// for (var key in area_data) {
	//   var k = String(key);
	//   if ( k.indexOf(defval) === 0 && k.substr(-2)!='00' ) {
	// 	var op = document.createElement('option');
	// 	op.value = k, op.innerHTML = area_data[k];
	// 	if ( $('#field_district').attr('default') && $('#field_district').attr('default') == k  ) {
	// 	  op.selected = true;
	// 	}
	// 	district_ele.append(op);		
	//   }
	// }
	// district_ele.attr('default','');
 //  });
	// $.getJSON("{{ route('area.province') }}", function (data){
	// 	console.info(data.data);
	//   area_data = data.data;
	//   var province_ele = $('#field_province');
	//   for (var obj in area_data) {
	// 	var k = String(obj.key);
	// 	if ( k.indexOf('0000') == 2 || k.indexOf('0000') == 1)  {
	// 	  var op = document.createElement('option');
	// 	  op.value = k, op.innerHTML = area_data[k];
	// 	  if ( province_ele.attr('default') &&  province_ele.attr('default') == k ) {
	// 		op.selected = true;
	// 	  }
	// 	  province_ele.append(op);
	// 	}
		
	//   }
	//   if ( province_ele.attr('default')) {
	// 	$('#field_province').trigger('change');
	//   }
	  
	// });
</script>
@stop